from tortoise import fields
from .base import BaseModel, TimestampMixin

class Commission(BaseModel, TimestampMixin):
    orders_id = fields.IntField(default=0, max_length=10, description="订单id")
    orders_goods_id = fields.IntField(default=0, max_length=10,null=True, description="orders_goods表id")
    goods_id = fields.IntField(default=0, max_length=10, null=True,description="商品id")
    grow_id = fields.IntField(default=0, max_length=10, null=True,description="培育模板id")
    goods_price = fields.DecimalField(max_digits=10, null=True,decimal_places=2, description="商品金额")
    orders_user_id = fields.IntField(default=0, max_length=10,null=True, description="用户id")
    user_id = fields.IntField(default=0, max_length=10, null=True,description="收益用户id")
    user_level = fields.IntField(default=0, max_length=10,null=True, description="收益用户等级")
    level = fields.IntField(default=0, max_length=10,null=True, description="收益层级[1直接,2间接,3...]")
    price = fields.DecimalField(max_digits=10, null=True,decimal_places=2, description="收益金额")
    status = fields.IntField(default=0, null=True,description="0待审核1已审核")
    space_id = fields.IntField(null=0, max_length=10, description="门店id")

    class Meta:
        table = "marketing_commission"

class IntegralRole(BaseModel, TimestampMixin):
    name = fields.CharField(max_length=255, description="名称")
    value = fields.IntField(default=0,null=True, max_length=10, description="收益用户id")
    role = fields.CharField(max_length=255,null=True, description="规则")
    remark = fields.CharField(max_length=255,null=True, description="备注")
    state = fields.BooleanField(default=True,null=True, description="是否激活")
    class Meta:
        table = "marketing_integral_role"

class Integral(BaseModel, TimestampMixin):
    user_id = fields.IntField(default=0, max_length=10, description="用户id")
    price = fields.DecimalField(max_digits=10, decimal_places=2, description="变动金额")
    direction = fields.IntField(default=1, null=True,max_length=10, description="变动方向1增加2减少")
    type = fields.IntField(default=0, null=True,max_length=10, description="积分类型")
    type_id = fields.IntField(default=0,null=True, max_length=10, description="类型值")
    expire_at = fields.DatetimeField(null=True,max_length=255, description="过期时间")
    remark = fields.CharField(max_length=255,null=True, description="备注")
    space_id = fields.IntField(null=0, max_length=10, description="门店id")

    class Meta:
        table = "marketing_integral"

class Lives(BaseModel, TimestampMixin):
    name = fields.CharField(max_length=255, null=True,description="直播名称")
    cover = fields.CharField(max_length=255, null=True,description="直播间封面")
    button_image = fields.CharField(max_length=255, null=True,description="进入按钮")
    share_image = fields.CharField(max_length=255, null=True,description="分享图")
    goods_ids = fields.JSONField(null=True, description="直播统计商品")
    begin_time = fields.DatetimeField(null=True, max_length=255, description="直播开始时间")
    state = fields.BooleanField(default=True, description="是否激活")
    class Meta:
        table = "marketing_lives"

class DrawlRole(BaseModel, TimestampMixin):
    name = fields.CharField(max_length=255, description="奖品名称")
    type = fields.IntField(default=0, max_length=10,null=True, description="奖品类型0未中奖1折扣2优惠券3商品4积分")
    type_id = fields.IntField(default=0, max_length=10,null=True, description="关联id")
    cover = fields.CharField(max_length=255, null=True,description="封面")
    value = fields.IntField(default=0, max_length=10,null=True, description="总数量")
    role = fields.IntField(default=0, max_length=10,null=True, description="中奖概率")
    remark = fields.CharField(max_length=255,null=True, description="备注")
    state = fields.BooleanField(default=True, description="是否激活")
    class Meta:
        table = "marketing_draw_role"

class Draw(BaseModel, TimestampMixin):
    user_id = fields.IntField(default=0, max_length=10, description="用户id")
    is_got = fields.IntField(default=0, max_length=10, description="是否中奖1中奖")
    draw_id = fields.IntField(default=0, max_length=10, description="奖品id")
    space_id = fields.IntField(default=0, max_length=10, description="门店id")
    order_id = fields.IntField(default=0,null=True,  max_length=10, description="订单id")
    status = fields.IntField(default=0, max_length=10, description="0未兑奖1已兑奖")
    up_time = fields.DatetimeField(null=True, max_length=255, description="兑奖时间")
    class Meta:
        table = "marketing_draw"


class CouponsRole(BaseModel, TimestampMixin):
    name = fields.CharField(max_length=255, null=True,description="优惠券名称")
    cover = fields.CharField(max_length=255,null=True, description="封面")
    value = fields.IntField(default=0, null=True,max_length=10, description="面额")
    goods_ids = fields.JSONField(null=True, description="可使用商品")
    role = fields.IntField(default=0,null=True, max_length=10, description="使用起点")
    expire_at = fields.IntField(default=0,null=True, max_length=10, description="过期天数")
    remark = fields.CharField(max_length=255,null=True, description="备注")
    state = fields.BooleanField(default=True, description="是否激活")
    class Meta:
        table = "marketing_coupons_role"

class Coupons(BaseModel, TimestampMixin):
    user_id = fields.IntField(default=0, max_length=10, description="用户id")
    coupons_id = fields.IntField(default=0, max_length=10, description="优惠券ID")
    coupons_price = fields.IntField(default=0, max_length=10, description="面额")
    expire_at = fields.DatetimeField(null=True, max_length=255, description="过期时间")
    is_used  = fields.IntField(default=0, max_length=10, description="0未使用1已使用")
    order_id = fields.IntField(default=0,null=True, max_length=10, description="使用的订单ID")
    add_order_id = fields.IntField(default=0,null=True, max_length=10, description="生成的订单ID")
    order_goods_id = fields.IntField(null=0, max_length=10, description="订单商品表id")
    remark = fields.CharField(null=True,max_length=255, description="备注")
    come_type = fields.IntField(default=1,null=True, max_length=10, description="获得方式1手动发放2商品3抽奖")
    space_id = fields.IntField(null=0, max_length=10, description="门店id")
    class Meta:
        table = "marketing_coupons"

class Deposit(BaseModel, TimestampMixin):
    user_id = fields.IntField(default=0, max_length=10, description="用户id")
    price = fields.DecimalField(max_digits=10, decimal_places=2, description="变动金额")
    direction = fields.IntField(default=1, max_length=10, description="变动方向1增加2减少")
    order_id = fields.IntField(null=True, max_length=10, description="订单id")
    order_goods_id = fields.IntField(null=True, max_length=10, description="订单商品表id")
    goods_id = fields.IntField(null=True, max_length=10, description="商品id")
    goods_num = fields.IntField(null=True, max_length=10, description="购买数量")
    remark = fields.CharField(max_length=255,null=True, description="备注")
    zs_price = fields.DecimalField(default=0,max_digits=10, decimal_places=2, description="赠送金额")
    space_id = fields.IntField(null=0, max_length=10, description="门店id")

    class Meta:
        table = "marketing_deposit"

class LevelIntegral(BaseModel, TimestampMixin):
    user_id = fields.IntField(default=0, max_length=10, description="用户id")
    price = fields.DecimalField(max_digits=10, decimal_places=2, description="变动数量")
    direction = fields.IntField(default=1, null=True,max_length=10, description="变动方向1增加2减少")
    remark = fields.CharField(max_length=255,null=True, description="备注")
    order_id = fields.IntField(default=0, null=True, max_length=10, description="类型id或者订单id")

    class Meta:
        table = "marketing_level_integral"